<template>
  <div>
    <el-dialog
        title="角色详细信息"
        :visible.sync="showRoleInfo"
        width="40%" @close="setShowRoleInfo(false)">
        <el-form label-width="80px">
            <el-form-item label="角色名称">
                {{roleObj.name}}
            </el-form-item>

            <el-form-item label="拥有权限">
              {{getGradeInfo()}}
            </el-form-item>

        </el-form>

        <span slot="footer" class="dialog-footer">
            <el-button @click="setShowRoleInfo(false)" type="primary">确定</el-button>
        </span>
        </el-dialog>
  </div>
</template>

<script>
import {mapState,mapMutations} from "vuex"
export default {
  computed:{
        ...mapState('role',['roleObj']),
        showRoleInfo:{
          set(isSow){
            this.setShowRoleInfo(isSow);
          },
          get(){
            return  this.$store.state.role.showRoleInfo
          }
        }
    },
    methods:{
        ...mapMutations('role',['setShowRoleInfo']),
        getGradeInfo(){//拼接权限信息字符串
          if(this.roleObj.gradeList == undefined){
            return;
          }
          var str = "";
            for(var i=0;i<this.roleObj.gradeList.length;i++){
                str += this.roleObj.gradeList[i].name+"、";
            }
            return str.substring(0,str.length-1);
        }
    }

}
</script>

<style>

</style>